import  re

# * 匹配0个或多个字符
print('-'*20,'* 匹配0个或多个字符','-'*20)
m1 = re.match('h*','hello')
print(m1.group())

m2 = re.match('.*','hello world')
print(m2.group())
# 2. + 匹配1个或多个字符
print('-'*20,'+ 匹配1个或多个字符','-'*20)
m3 = re.match('p.+n','python is a good language')
print(m3.group())

# 3. ? 匹配0个或1个字符
print('-'*20,'? 匹配0个或1个字符','-'*20)
m4 = re.match('https?','https://www.google.com')
print(m4.group())

# 4. {n} 匹配n个字符
print('-'*20,'{n} 匹配n个字符','-'*20)
m5 = re.match('\w{3}','python')
print(m5.group())

# 5. {n,} 匹配n个或更多字符
print('-'*20,'{n,} 匹配n个或更多字符','-'*20)

m6 = re.match('\w{3,}','python3')
print(m6.group())

# 6. {,m} 匹配0到m个字符
print('-'*20,'{,m} 匹配0到m个字符','-'*20)
m7 = re.match('\w{,3}','python')
print(m7.group())

# 7. {n,m} 匹配n到m个字符
print('-'*20,'{n,m} 匹配n到m个字符','-'*20)
m8 = re.match('\w{3,5}','python3')
print(m8.group())
